package cn.fl.insroute.service.impl;

import java.util.List;

import cmm.mid.core.framework.dto.DataResultDTO;
import cn.fl.insroute.api.IInsRouteModifyApiService;
import cn.fl.insroute.api.IInsRouteQueryApiService;
import cn.fl.insroute.condition.InsRouteInsResQC;
import cn.fl.insroute.dto.InsRouteBscInfoDTO;
import cn.fl.insroute.voTransform.InsRouteInsResVOTransform;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.fl.insroute.dto.InsRouteInsResDTO;
import cn.fl.insroute.service.IInsRouteInsResService;
import cn.fl.insroute.vo.InsRouteInsResVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;

/**
 * @Description: 资管路由机构筛选结果 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class InsRouteInsResServiceImpl implements IInsRouteInsResService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(IInsRouteInsResService.class);
	
	/**
	 * TODO 自定义 API 暴露服务
	 */
	//@Autowired
	//private I自定义ApiService 自定义ApiService;

	@Autowired
	private IInsRouteQueryApiService iInsRouteQueryApiService;

	@Autowired
	private IInsRouteModifyApiService iInsRouteModifyApiService;

	@Override
	public InsRouteInsResVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//TODO 业务逻辑
		InsRouteInsResDTO dto = null;//this.自定义ApiService.selectById(id);
		return InsRouteInsResVOTransform.toVO(dto);
	}

	@Override
	public Long add(InsRouteInsResVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//return this.insRouteInsResApiService.add(InsRouteInsResVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return null;
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		//return this.insRouteInsResApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
    		BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(InsRouteInsResVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		//return this.insRouteInsResApiService.modify(InsRouteInsResVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		//return this.insRouteInsResApiService.searchListPage(page);
		//TODO 业务逻辑
		return null;
	}

	@Override
	public List<InsRouteInsResVO> searchList(InsRouteInsResQC insRouteInsResQC) throws BaseException {
		return InsRouteInsResVOTransform.toVOList(this.iInsRouteQueryApiService.searchInsRouteInsResDTOList(insRouteInsResQC));
	}

	@Override
	public DataResultDTO routeRes(InsRouteBscInfoDTO insRouteBscInfoDTO) throws BaseException {
    	BaseLogUtils.info(logger,"routeRes","筛选结果.请求参数insRouteBscInfoDTO：" + JSON.toJSONString(insRouteBscInfoDTO),CurrentThreadContext.getCurrentUserName());
		DataResultDTO resultDTO = this.iInsRouteQueryApiService.routeRes(insRouteBscInfoDTO);
		BaseLogUtils.info(logger,"routeRes","筛选结果.返回结果resultDTO：" + JSON.toJSONString(resultDTO),CurrentThreadContext.getCurrentUserName());
		return null;
	}

	@Override
	public boolean modifyInfo(Long routeId, Long mediationFeeAmt) throws BaseException {
		return this.iInsRouteModifyApiService.modifyInfo(routeId,mediationFeeAmt);
	}
}
